import { useQueries } from "react-query";
import { StudentColumns } from "../types";
import { studentKeys } from "./query-keys";

function useStudentQueries(ids: string[]){
	return useQueries(
		ids.map(id =>{
			return {
				queryKey: studentKeys.details(id),
				queryFn: async ()=>{
					const res: StudentColumns = await fetch(`http://localhost:5000/students/${id}`,{
						headers: {
							'Content-type': 'application/json',
						}
					}).then(res => res.json())
					return res
				}
			}
		})
	)
}

export default useStudentQueries;